import {
	ajax,
	baseUrl
} from "@/utils/request.js";
/**------------------------------登录相关---------------------------------------*/
// 短信验证登录
export const smsCodeLogin = data => ajax({
	url: '/open/login/phone/code?phone=' + data.phone + '&code=' + data.code + '&source=' + data.source,
	method: 'POST'
});
// 账号密码登录
export const userLogin = (data) => ajax({
	url: `/open/login/account?userName=${data.userName}&password=${data.password}`,
	method: 'POST'
});
// 获取验证码  	发送类型(1 ：登录,2：注册,3：绑定手机号)
export const msgCode = data => ajax({
	url: '/open/login/send/msg',
	data,
	method: 'POST'
});
// 注册
export const register = data => ajax({
	url: `/open/user/register`,
	data,
	method: 'POST',
});

// 记录用户登录
export const activeUser = () => ajax({
	url: `/api/member/update/launchTime`,
	method: 'GET',
})
//openid	微信OpenId
// unionid	微信返回的unionid
// 绑定微信
export const bindwx = data => ajax({
	url: `/api/bind/wx`,
	data,
	method: 'POST',
});
// 解除微信绑定
export const unbindwx = () => ajax({
	url: `/api/unbind/wx`,
	method: 'PUT',
});
//微信登录
export const wxlogin = data => ajax({
	url: `/open/login/wx`,
	data,
	method: 'POST'
})
// 微信登录绑定手机号
export const bindPhone = data => ajax({
	url: `/open/login/wx/binding/phone`,
	data,
	method: 'POST',
});
// 退出登录
export const logout = data => ajax({
	url: `/api/sign/out`,
	method: 'POST',
});
//注销账号
export const cancelAccount = data => ajax({
	url: `/api/logout`,
	method: 'POST',
});

// 微信小程序登录
export const wxMpLogin = data => ajax({
	url: `/open/login/wx/code/post`,
	data,
	method: 'POST'
})
// 微信小程序获取手机号
export const getPhoneNumber = data => ajax({
	url: `/open/login/getPhoneNumber`,
	data,
	method: 'POST'
})

// 解密用户信息
export const postCodeUserInfo = data => ajax({
	url: `/open/login/wx/code/post/userInfo`,
	data,
	method: 'POST'
})

// 协议富文本
//文案类型（0：隐私政策，1：拼单规则,2:会员权益，3：会员服务协议，4创作中心文案说明）
export const getCopywriting = (type) => ajax({
	url: `/open/commons/copywriting?type=${type}`,
	method: 'GET',
});

/**  -----------------------------------------------字典-----------------------------*/
// 字典
export const commonsType = type => ajax({
	// sys_feedback_type 投诉类型
	url: `/open/commons/type/${type}`,
	method: 'GET',
});
/**  -----------------------------------------------话题-----------------------------*/

// 热门话题库列表
export const hotTopic = data => ajax({
	url: `/open/dynamic/hot/list`,
	data,
	method: 'GET',
});

// 话题列表
export const topicList = data => ajax({
	url: `/open/dynamic/list`,
	data,
	method: 'GET',
});

// 添加话题
export const addTopic = data => ajax({
	url: `/api/dynamic/add`,
	data,
	method: 'POST',
	contentType: 'application/json'
});

// 添加话题
export const editTopic = data => ajax({
	url: `/api/dynamic/edit`,
	data,
	method: 'POST',
	contentType: 'application/json'
});

// 话题详情
export const topicDetail = dynamicId => ajax({
	url: `/api/dynamic/details/${dynamicId}`,
	method: 'GET',
});

// 我的话题列表
//getType（1：我发布的，2：我查看的）
export const memberTopic = data => ajax({
	url: `/api/dynamic/list/member`,
	data,
	method: 'GET',
});

// 删除我的话题
export const delTopic = id => ajax({
	url: `/api/dynamic/del/${id}`,
	method: 'POST',
});


/**  ---------------------------------------评论、点赞、收藏、分享-----------------------------*/
// 收藏
// objectType	业务数据类型（0：课程，1：话题，2：评论）
export const addOrClean = data => ajax({
	url: `/api/service/collection/addOrClean`,
	data,
	method: 'POST',
});
// 增加阅读数
export const addReadNum = data => ajax({
	//resourceId
	url: `/api/course/resource/details/add/read`,
	data,
	method: 'PUT',
});

//发布评论
export const addComment = data => ajax({
	url: `/api/service/comment/add`,
	data,
	method: 'POST',
});

//一级评论列表
export const parentComment = data => ajax({
	url: `/api/service/comment/parent/list`,
	data,
	method: 'GET',
});

//二级评论列表
export const childComment = data => ajax({
	url: `/api/service/comment/child/list`,
	data,
	method: 'GET',
});

// 点赞
//业务数据类型（0：课程，1：话题，2：评论）
export const addGreat = data => ajax({
	url: `/api/service/great`,
	data,
	method: 'POST',
});
// 分享
// 分享方式（1：微信好友，2：微信朋友圈，3：复制链接）
// 业务数据类型（0：课程，1：话题）
export const shareAdd = data => ajax({
	url: `/api/service/share/add`,
	data,
	method: 'POST',
});
/**  -----------------------------------------------我的页面-----------------------------*/
// 获取用户信息
export const getUserInfo = data => ajax({
	url: `/api/user/getInfo`,
	method: 'GET',
	data,
});

// 用户基础数据
export const getUserData = data => ajax({
	url: `/api/member/basic/data`,
	method: 'GET',
});

// 修改密码
export const updatePwd = data => ajax({
	url: `/api/member/update/password`,
	data,
	method: 'POST',
});
//用户设置密码
export const setPwd = data => ajax({
	url: `/api/member/set/password`,
	data,
	method: 'POST',
});

// 修改个人资料
export const updateUser = data => ajax({
	url: `/api/member/update/user`,
	data,
	method: 'POST',
});

// 个人资料详情
export const userDetails = data => ajax({
	url: `/api/member/get/user/details`,
	method: 'POST',
});

// 个人海报
export const userPoster = data => ajax({
	url: `/api/member/poster`,
	method: 'GET',
});

// 会员权益
export const vipEquity = data => ajax({
	url: `/api/member/vip/equity/list`,
	method: 'GET',
});
export const vipEquityID = id => ajax({
	url: `/api/member/vip/equity/${id}`,
	method: 'GET',
});
// 会员时长记录
export const vipRecord = data => ajax({
	url: `/api/member/vip/record/list`,
	data,
	method: 'GET',
});

// 会员套餐列表
export const vipSpecList = data => ajax({
	url: `/api/member/vip/list`,
	method: 'GET',
});

// 我的分享 课程
export const shareCourseRecords = data => ajax({
	url: `/api/service/share/member/kc/list`,
	data,
	method: 'GET',
});

// 我的分享 话题
export const shareTopicRecords = data => ajax({
	url: `/api/service/share/member/ht/list`,
	data,
	method: 'GET',
});

// 提交投诉意见
export const submitOpinion = data => ajax({
	url: `/api/commons/add/feedback`,
	data,
	method: 'POST',
	contentType: "application/json;charset=UTF-8"
});


// 提交商务合作
export const submitCooperation = data => ajax({
	url: `/api/member/save/cooperation`,
	data,
	method: 'POST',
});

// 申请入驻讲师
export const lecturerApply = data => ajax({
	url: `/api/creative/center/lecturer/apply`,
	data,
	method: 'POST',
});
// 讲师入驻数据状态查询
export const lecturerInStatus = data => ajax({
	url: `/api/creative/center/lecturer/apply/flag`,
	method: 'GET',
});



// 收益详情 - 创作中心
export const getEarnings = data => ajax({
	url: `/api/creative/center/income/details`,
	method: 'GET',
});

// 收益明细 - 创作中心
export const getEarningsList = data => ajax({
	url: `/api/creative/center/income/record`,
	data,
	method: 'GET',
});

//讲师上传的课程列表
export const lecturerUploadCourse = data => ajax({
	url: '/api/member/uploaded/resources',
	method: 'GET'
});

// 申请提现
export const extractApply = data => ajax({
	url: `/api/member/cash/apply`,
	data,
	method: 'POST',
});

// 提现记录
export const extractRecord = data => ajax({
	url: `/api/member/cash/record`,
	data,
	method: 'GET',
});

// 收益分析
export const analysis = data => ajax({
	url: `/api/member/income/analysis`,
	method: 'GET',
});

// 收益分析 我的分享列表
export const shareList = data => ajax({
	url: `/api/member/share/list`,
	data,
	method: 'GET',
});

// 收益详情
export const incomeDetails = data => ajax({
	url: `/api/member/income/details`,
	method: 'GET',
});


// 创作中心 收益明细
export const incomeMoneyList = data => ajax({
	url: `/api/member/income/money/list`,
	data,
	method: 'GET',
});

// 收益详情 - 会员天数
export const incomeVipList = data => ajax({
	url: `/api/member/income/vip/list`,
	data,
	method: 'GET',
});

/**  -----------------------------------------------公共-----------------------------*/

// banner 轮播
export const getBanner = data => ajax({
	url: `/open/commons/banners`,
	method: 'GET',
});
// 屏蔽设置
export const CleanFn = data => ajax({
	url:`/api/service/shield/addOrClean`,
	data:data,
	method:'GET'
})

export const getBannerDetail = id => ajax({
	url: `/open/commons/banner/${id}`,
	method: 'GET',
});
/**  -----------------------------------------------文件上传-----------------------------*/
// 单文件上传
export const uploadFile = data => ajax({
	url: `/api/commons/upload`,
	file: data,
	method: 'POST',
});
// 多文件
export const uploadFiles = data => ajax({
	url: `/api/commons/uploads`,
	data,
	method: 'POST',
});

/**  -----------------------------------------------订单相关-----------------------------*/

// 创建订单
// spellFlag	是否拼单购买（0：否，1：是）
export const createOrder = data => ajax({
	url: `/api/order/insert`,
	data,
	method: 'POST',
});

// 订单详情
export const orderDetail = orderId => ajax({
	url: `/api/order/details/${orderId}`,
	method: 'GET',
});

// 正在拼单
export const isSpellsList = data => ajax({
	url: `/api/order/conduct/spells`,
	data,
	method: 'GET',
});

// 我的拼单
export const mySpellsList = data => ajax({
	url: `/api/order/my/spells`,
	data,
	method: 'GET',
});
// 拼单信息
export const spellsInfo = id => ajax({
	url: `/open/share/spells/${id}`,
	method: 'GET',
});

// 我的订单
export const myOrderList = data => ajax({
	//invoiceFlag	开票状态(0：未开票,2:已开票)
	url: `/api/order/list`,
	data,
	method: 'GET',
});

// 拉取支付宝支付
export const aliPay = data => ajax({
	url: `/api/pay/ali`,
	data,
	method: 'POST',
});

// 拉取微信支付
export const wxPay = data => ajax({
	url: `/api/pay/wx`,
	data,
	method: 'GET',
});
//开票详情
export const invoiceDetail = data => ajax({
	url: `/api/order/invoice/details`,
	data,
	method: 'GET'
})
//订单开票
export const orderInvoice = data => ajax({
	url: `/api/order/insert/invoice`,
	data,
	method: 'POST'
})
//开票历史
export const invoiceHistory = data => ajax({
	url: `/api/order/invoice/list`,
	method: 'GET'
})
/**  -----------------------------------------------课程相关-----------------------------*/

// 我的课程
export const myCourse = data => ajax({
	url: `/api/course/info/member/list`,
	data,
	method: 'GET',
});


//课程一二级分类
export const courseCategory = data => ajax({
	url: `/open/course/types`,
	method: 'GET',
});
// 分类详情
export const courseCateDetail = id => ajax({
	url: `/open/course/type/${id}`,
	method: 'GET',
});

//课程系列详情
export const seriesDetail = id => ajax({
	url: `/open/course/info/${id}`,
	method: 'GET',
});

//课程系列列表
export const courseSeries = data => ajax({
	url: `/open/course/info/list`,
	data,
	method: 'GET',
});

// 课程章节详情
export const courseDetail = id => ajax({
	url: `/api/course/resource/details/${id}`,
	method: 'GET',
});

//获取推荐课程
export const recommentCourse= data =>ajax({
	url:'/open/recommend/resource/list',
	method:'GET',
	data
})

// 课程章节列表
export const resourceList = data => ajax({
	// type 获取位置 （0：首页，1：系列课程）
	url: `/open/course/resource/list`,
	data,
	method: 'GET',
});


// 课程章节列表
export const chapterList = data => ajax({
	// type 获取位置 （0：首页，1：系列课程）
	url: `/api/resource/info/member/list`,
	data,
	method: 'GET',
});


//课程小测详情
export const testDetail = id => ajax({
	// url: `/api/course/resource/test/details/${id}`,
	url: `/api/course/resource/test/details/testId/${id}`,
	method: 'GET',
});

// 提交小测
export const testAdd = data => ajax({
	url: `/api/course/resource/test/add`,
	data,
	method: 'POST',
	contentType: 'application/json;charset=utf-8'
});

// 小测记录列表
export const testRecords = data => ajax({
	url: `/open/course/resource/test/list`,
	data,
	method: 'GET',
});
// 小测结果详情
export const testResult = data => ajax({
	// testMemberId  测试记录ID
	url: `/api/course/resource/test/result/member`,
	data,
	method: 'GET',
});

//学习记录
export const studyRecords = data => ajax({
	url: `/api/course/info/learning/records`,
	data,
	method: 'GET',
});
//学习历史
export const studyHistory = data => ajax({
	url: `/api/add/study/info`,
	data,
	method: 'POST',
});
//我的收藏
export const collection = data => ajax({
	url: `/api/service/collection/kc/member/list`,
	data,
	method: 'GET',
});

/**------------------------------------------------主页------------------------------*/

//消息；列表
export const messageList = data => ajax({
	// revcNoticeType	查看数据类型（0:系统消息 1:订单消息，2：动态消息）
	url: `/api/message/list`,
	data,
	method: 'GET',
});

// 消息未读数量
export const unreadNum = data => ajax({
	url: `/api/message/unread/num`,
	method: 'GET',
});

// 消息未读数量==分类
export const unreadCate = data => ajax({
	url: `/api/message/diff/unread/num`,
	method: 'GET',
});

// 消息标注为已读
export const setMessageRead = data => ajax({
	//messageIds 	消息Id,多条消息用逗号分开
	url: `/api/message/read`,
	data,
	method: 'GET',
});

// 消息详情
export const messageDetails = id => ajax({
	//messageIds 	消息Id,多条消息用逗号分开
	url: `/api/message/details/${id}`,
	method: 'GET',
});

// 消息详情
export const messageDynamicDetail = id => ajax({
	//messageIds 	消息Id,多条消息用逗号分开
	url: `/api/message/dynamic/details/${id}`,
	method: 'GET',
});

// 开屏页
export const pageIndex = id => ajax({
	url: `/open/commons/open`,
	method: 'GET',
});

// 版本更新
export const versionUpdate = id => ajax({
	url: `/open/commons/version/update`,
	method: 'GET',
});

//搜索
export const searchCourse = kw => ajax({
	url: `/open/search/list?kw=${kw}`,
	method: 'GET',
});



// add to 2022.12.25
/****************    app v2 apis    *********************/
// 标签树
export const industryTreeAll = data => ajax({
	url: `/api/v2/label/tree/all`,
	method: 'GET',
	data
});

//搜索标签
export const industrySearch = data => ajax({
	url: `/api/v2/post/search`,
	method: 'GET',
	data
});

// 修改用户标签信息
export const updateMemberLabel = data => ajax({
	url: `/api/v2/update/member/label`,
	method: 'put',
	data,
	contentType: 'application/json'
});

// 获取用户标签（行业、兴趣等）信息
export const memberLabel = data => ajax({
	url: `/api/v2/member/label`,
	method: 'GET',
	data
});

// 获取已知菜单首页数据
export const getYzHome = data => ajax({
	url: `/api/v2/yz/home`,
	method: 'GET',
	data
});

// 获取兴趣分类推荐系列课程  labelInterestId	兴趣ID  integer(int64)
export const getMemberInterestCourse = data => ajax({
	url: `/api/v2/member/label/course`,
	method: 'GET',
	data
})


// 获取岗位子标签  labelId岗位id
export const getIndustrySubLabel= data => ajax({
	// url: `/api/v2/label/sub`,
	url:`/api/v2/label/tree/all`,
	method: 'GET',
	data
})

// 查询字典数据列表
export function listDictData(query) {
  return ajax({
    url: '/api/system/dict/data/list',
    method: 'get',
    params: query
  })
}



// v2 学习历史接口
export const learningRecordV2 = (data)=> {
  return ajax({
    url: '/api/v2/member/learning/record',
    method: 'get',
    data
  })
}


// v2 记录页面数据埋点 startTime endTime timer 
//pageType-页面枚举类型（1：会员权益，2：收益中心，3：创作中心，4：话题主页）
export const savePageRecord = (data)=> {
  return ajax({
    url: '/api/v2/save/pageRecord',
    method: 'post',
    data,
	contentType: 'application/json'
  })
}


